package com.homegoods.login.model;

import android.content.Context;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.utils.TextUtils;
import com.alibaba.fastjson.JSON;
import com.homegoods.aroutercomment.UserService;
import com.homegoods.aroutercomment.ARouterPath;
import com.homegoods.classify.model.Constant;

/**
 * @author QiQi
 * @ClassName: UserServiceImpl
 * @date 2018/9/15
 * @description
 */
@Route(path = ARouterPath.PATH_USER_SERVICE, name = "用户资料提供")
public class UserServiceImpl implements UserService {
    @Override
    public String getUserId() {
        return UserProxy.getInstance().getUserID();
    }

    @Override
    public String getHeadImg() {
        //add shibo.zheng start
        if (TextUtils.isEmpty(UserProxy.getInstance().getHeadImg())){
            return "";
        }   //add shibo.zheng end
        if (UserProxy.getInstance().getHeadImg().contains("http")) {
            return UserProxy.getInstance().getHeadImg();
        }
        return Constant.SERVER_URL + UserProxy.getInstance().getHeadImg();
    }

    @Override
    public void setHeadImg(String img) {
        //TODO
    }

    @Override
    public String getNiName() {
        return UserProxy.getInstance().getNickName();
    }

    @Override
    public void setNiName(String roleName) {
        UserProxy.getInstance().setNickName(roleName);
    }

    @Override
    public String getMobile() {
        return UserProxy.getInstance().getMPhone();
    }

    @Override
    public String getRoleName() {
        return UserProxy.getInstance().getRoleName();
    }


    @Override
    public String getToken() {
        return UserProxy.getInstance().getToken();
    }

    @Override
    public String getSid() {
        return UserProxy.getInstance().getSid();
    }

    @Override
    public String getBalance() {
        return UserProxy.getInstance().getCapitalVol();
    }

    @Override
    public String getPushSign() {
        return UserProxy.getInstance().getPushSign();
    }

    @Override
    public void setUserModel(String userModelJson) {
        UserProxy.getInstance().setUserModel(userModelJson);
    }


    @Override
    public void outLogin() {
        UserProxy.getInstance().loginOut();
    }

    @Override
    public String getClientUser() {
        return JSON.toJSONString(UserProxy.getInstance().getClientUser());
    }


    @Override
    public void init(Context context) {
        UserProxy.getInstance().init(context);
    }
}
